package com.daedalus.Gui.login;/*
 * Created with IntelliJ IDEA.
 * Author: Kostika Gorica
 * Date: 12-12-18
 * Time: 1.45.MD
 */

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Login2 extends JPanel implements ActionListener{

    JLabel emri;
    JLabel pass;
    JTextField user;
    JPasswordField passw;
    JTextArea area;
    JButton button;

    public Login2(){
        setLayout(new BorderLayout(10,10));
        setSize(400,300);

        JPanel input = new JPanel(new GridLayout(3,2));
        emri=new JLabel("User Name");
        pass=new JLabel("password");
        user=new JTextField();
        passw=new JPasswordField();
        area=new JTextArea();
        area.setEditable(false);

        button=new JButton("Insert");

        JScrollPane pane=new JScrollPane(area);
        pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);

        input.add(emri);
        input.add(user);
        input.add(pass);
        input.add(passw);
        input.add(new JLabel("Butoni: "));
        input.add(button);
        add(input, BorderLayout.NORTH);
        add(pane, BorderLayout.CENTER);

        button.addActionListener(this);

    }

    public static void main(String[] args){
        JFrame frame = new JFrame("Login");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(500,400);
        frame.getContentPane().add(new Login2());
        frame.setVisible(true);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if(e.getSource()==button){
            String s=String.format("Username: %s  Password: %s ", user.getText(),new String(passw.getPassword()));
            area.setText(s);
        }
    }
}
